﻿#include <iostream>
#include "Server.h"
#include <boost/asio.hpp>
#include "AsioIOContextPool.h"
int main()
{
	try {
		boost::asio::io_context ioc;
		Server server(ioc, 3333);
		boost::asio::signal_set signals(ioc, SIGINT, SIGTERM);
		signals.async_wait([&ioc](auto, auto){
			//线程池在创建Server的时候启动了，要记得stop
			AsioIOContextPool::GetInstance().Stop();
			ioc.stop();
		});
		ioc.run();
	}
	catch (boost::system::error_code & e){
		std::cout << "Server error: " << e.what() << std::endl;
	}
}